package com.huli.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huli.domain.PropertyCompany;
import com.huli.dto.OrdersInfoDto;
import com.huli.dto.PropertyCompanyDto;
import com.huli.param.AppealParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PropertyCompanyMapper extends BaseMapper<PropertyCompany> {

    //查询所有物业的联系方式
    @Select("SELECT property_company_id,property_company_name,property_company_account,property_company_phone FROM property_company")
    public List<PropertyCompanyDto> selectAllPropertyPhone();

    //查询车库订单详情
    @Select("SELECT\n" +
            "\tgarage.garage_id, \tgarage.property_company_id, garage.garage_address,\tcarport.carport_id, \tcarport.owner_id, \tcarport.carport_price,carport.carport_status, \t`owner`.owner_nickname, \t`owner`.owner_name, \t`owner`.owner_sex, `owner`.owner_phone, \torders.orders_id, \t \torders.orders_start_time, \torders.orders_end_time, \torders.coupon_id, \torders.orders_money, \torders.orders_status\n" +
            "FROM\torders,`owner`,\tcarport,\tgarage\n" +
            "WHERE\n" +
            "\torders.carport_id = carport.carport_id AND\n" +
            "\t`owner`.owner_id = carport.owner_id AND\n" +
            "\tcarport.garage_id = garage.garage_id AND\n" +
            "\tgarage.garage_id = #{garageId}\n" +
            "\t")
    public  List<OrdersInfoDto> selectCarportOrdersInfo(int garageId);

    //生成申述表
    @Insert("INSERT INTO appeal  (orders_id,appeal_contnet,appeal_phone) VALUES (#{ordersId},#{appealContnet},#{appealPhone})")
    public void createAppeal(AppealParam appealParam);
}
